package com.yn.pet.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

@AllArgsConstructor
@Getter
public enum DeviceModelEnum {

    // 耗电模式，code 对应 1
    POWER_CONSUMPTION(1, "耗电模式"),
    // 省电模式，code 对应 2
    POWER_SAVING(2, "省电模式"), 
    // 超级省电模式，code 对应 3
    SUPER_POWER_SAVING(3, "超级省电模式"); 

    private Integer code;
    private String name;

    public static DeviceModelEnum getByCode(Integer code) {
        if (code == null) {
            return null;
        }
        for (DeviceModelEnum modeEnum : DeviceModelEnum.values()) {
            if (modeEnum.getCode().equals(code)) {
                return modeEnum;
            }
        }
        return null;
    }
}